# Use Python slim image as the base
FROM python:3.13-slim

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Install system dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    git \
    curl \
    build-essential \
    libpq-dev \
    && apt-get purge -y --auto-remove curl \
    && rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /app

# Copy the project into the image
ADD . /app

# Install dependencies and sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --locked

ARG RELEASE
ENV RELEASE=$RELEASE
ENV PATH="/app/.venv/bin:$PATH"

# Command to run the application
CMD ["uvicorn", "app.api:app", "--host", "0.0.0.0", "--port", "80"]
